<template>
  <div id="Welcome">
    <el-container>
      <el-header>
        <el-row>
          <el-col :lg="9" :xl="10">
            <div class="title_wel">自然语言处理平台</div>
          </el-col>
          <el-col :lg="9" :xl="10">
            <div class="notice">
              <font-awesome-icon class="icon bell" icon="volume-up" />
              <div class="noticedata">
                <marquee>自然语言处理平台</marquee>
              </div>
            </div>
          </el-col>
          <el-col :lg="6" :xl="4">
            <el-menu active-text-color="#ffd04b" class="unhandle" mode="horizontal" @select="handleSelect">
            
              <el-submenu popper-class="submenu-title" index="2">
                <template slot="title">{{username}}</template>
                <el-menu-item index="logout" @click="logout()">退出</el-menu-item>
              </el-submenu>
            </el-menu>
          </el-col>

        </el-row>
      </el-header>
      <el-container>
        <el-aside>
          <el-menu @select="handleSelect" default-active="userManage" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose">
            
            <el-menu-item index="userManage">
                <i class="el-icon-edit"></i>
                <span slot="title">用户管理</span>
              </el-menu-item>
              <el-menu-item index="command">
                <i class="el-icon-star-off"></i>
                <span slot="title">动作命令集管理</span>
              </el-menu-item>
            </el-submenu>
          </el-menu>
         
          <br />
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>

      </el-container>
    </el-container>
  </div>
</template>

<script>
import userManage from "./userManage.vue";
import command from './command.vue';
import store from "../store";
import router from "../router";
export default {
  name: "Welcome",
  components: {
    userManage,
    command
  },
  data() {
    return {
      isCollapse: true,
      dialogVisible: false,
      username:'',
      loginParam: {
        name: "",
        oldPassword: "",
        newPassword: "",
        nameError: "",
        oldPasswordError: "",
        newPasswordError: ""
      },
      unhandleData: {
        allotrecordlist: 0,
        inventorylist: 0,
        qualitylist: [0, 0, 0, 0, 0, 0]
      }
    };
  },
  created() {
    this.username = localStorage.getItem('username'); 
  },
  mounted: function() {},
  beforeRouteEnter(to, from, next) {
    // 在渲染该组件的对应路由被 confirm 前调用
    // 不！能！获取组件实例 `this`
    // 因为当守卫执行前，组件实例还没被创建
    if (!window.store) {
      router.replace("Login");
      next(false);
    } else {
      next();
    }
    
  },
  methods: {
    handleOpen(key, keyPath) {
      //console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      //console.log(key, keyPath);
    },
    // 界面跳转
    handleSelect(index, indexPath, e) {
      this.$router.replace(index)
    },
    // 退出登录
    logout(){
      router.replace('Login');
    }
  }
};
</script>

<style>
#Welcome {
  width: 100%;
  height: 100%;
}
.el-container {
  height: 100%;
  overflow: hidden;
}
.el-header,
.el-footer {
  background-color: #545C64;
  color: #333;

  line-height: 50px;
  height: 50px !important;
}
.title_wel{
  color: #fff;
}
.user {
  line-height: 1rem;
  margin-top: 17px;
  color: #fff;
}
.el-dropdown-link {
  color: #fff;
}
.el-aside {
  background-color: #fff;
  color: #333;
  line-height: 50px;
  width: auto !important;
}

.el-main {
  background-color: #F5F7F9;
  color: #333;
  padding: 20px !important;
}
.el-menu {
}
.menu .el-submenu__title {
  min-width: 200px;
}

.menu .el-submenu > ul {
  background-color: #c7cbd5;
}
.menu .el-menu-item,
.menu .el-submenu__title {
  height: 46px !important;
  line-height: 46px !important;
}
.menu .el-submenu.is-opened .el-submenu__title {
  background-color: #74AFD2;
  color: #fff !important;
}
.menu .el-submenu.is-opened i {
  color: #fff !important;
}
.menu .el-menu-item.is-active {
  background-color: #ecf5ff;
}

.el-tabs--card > .el-tabs__header,
.el-tabs--card > .el-tabs__header .el-tabs__item {
  /* border-bottom: 1px solid #d0d1d2 !important; */
  background-color: #fff !important;
}
.el-tabs--card > .el-tabs__header .el-tabs__item.is-active {
  /* border-bottom-color: #fff !important; */
  background-color: #545C64 !important;
  color: #fff;
}
.el-tabs__item:hover {
  color: #fff !important;
}

.el-pagination {
  text-align: center;
  background-color: #fff;
  margin-top: 0px;
}

.center {
  text-align: center;
  margin-bottom: 20px;
}

.el-dialog__header {
  background-color: #ededed !important;
}
hr {
  border-top: none;
  border-bottom: 1px solid#DCDFE6;
  margin-bottom: 20px;
}
.notice {
  color: #fff;
  width: 100%;
  overflow: hidden;
}
.notice .bell {
  float: left;
  height: 50px;
}
.noticedata {
  float: left;
  height: 50px;
  margin-left: 10px;
  width: calc(100% - 40px);
}
marquee {
  letter-spacing: 2px;
}
.icon {
  margin-right: 10px;
  width: 15px !important;
  height: 15px;
}

.logo {
  height: 30px;
  vertical-align: middle;
}

.unhandle {
  z-index: 1000;
  background-color: rgba(0, 0, 0, 0) !important;
  border-bottom: none !important;
}

.unhandle .el-submenu__title {
  height: 50px !important;
  line-height: 50px !important;
  color: #fff !important;
}
.unhandle .el-submenu__title:hover {
  background-color: rgba(0, 0, 0, 0) !important;
}
.unhandle .el-submenu__title i {
  color: #fff !important;
}
.submenu-title {
  background-color: #fff;
}
.submenu-title .el-menu--popup {
  min-width: 150px !important;
}
.submenu-title .el-submenu .el-menu-item {
  min-width: 150px !important;
}
.smini {
  padding: 3px 5px !important;
  float: right;
  margin-top: 7.5px !important;
}
</style>
